﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace FocusClock.WPF
{
    public class DefaultCommand : ICommand
    {
        private readonly Func<object?, bool> canExecute;
        private readonly Action<object?> execute;

        public DefaultCommand(Func<object?,bool> _CanExecute,Action<object?> _Execute)
        {
            canExecute = _CanExecute;
            execute = _Execute;
        }

        public event EventHandler? CanExecuteChanged;

        public bool CanExecute(object? parameter)
        {
            return canExecute==null?false: canExecute.Invoke(parameter);
        }

        public void Execute(object? parameter)
        {
            execute?.Invoke(parameter);
        }
    }
}
